package org.example.config;

import lombok.extern.slf4j.Slf4j;
import org.example.interceptor.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Slf4j
public class AdminWebConfig implements WebMvcConfigurer {

    /*
    * 添加拦截器
    * */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor())
                .addPathPatterns("/**") // 拦截路径, /** 代表所有请求都被拦截，包括静态资源
                .excludePathPatterns("/login", "/static/**"); // 放行路径
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
